#ifndef BLOCK_H
#define BLOCK_H

#include "Buffer.h"
#include <vector>

class Message;
class MessageClientdata;
class MessageUpdateEntity;

class Block : public Buffer
{
public:
	Block(int Size) : Buffer(Size) {m_IsLast=false;};
	Block(FILE* file);
	Block(const Block& other);

	~Block();
	Block& operator=(const Block& Other);

	void Unparse();

	void SetBlockTime(float Time) const {m_Time=Time;};
	float GetBlockTime() {return m_Time;};

	bool IsLast() {return m_IsLast;};
	void SetLast() const {m_IsLast = true;};

	void AddMessage(Message* NewMessage);

	bool Write(FILE* file);

	void SnapToTime(float Time);

	void RenumberEntity(int OldId, int NewId);
	void ShiftEntity(int Id, int Offset[3]);
	void MergeInto(Block& pOther,int ClientNumber);

	MessageUpdateEntity* GetUpdateFor(int EntityId);

	MessageClientdata*	GetClientData() {return m_pClientData;}
private:
	void Parse();
	typedef std::vector<Message*> Messages;

	Messages	m_Messages;	
	mutable float		m_Time;

	mutable bool m_IsLast;

	MessageClientdata*	m_pClientData;
};

#endif 
